﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using coliseu.BussinessLayer;

namespace coliseu.Views.Condominio
{
    public partial class FrmListMorador : Form
    {
        private MoradorBL mBL = new MoradorBL(); 

        public FrmListMorador()
        {
            InitializeComponent();
        }

        private void FrmListMorador_Load(object sender, EventArgs e)
        {
            moradorBindingSource.DataSource = mBL.selecionar();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            pnlFundo.Visible = true;
        
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja excluir?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                mBL.excluir((morador)moradorBindingSource.Current);
                moradorBindingSource.DataSource = mBL.selecionar();
            }
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            FrmCadMorador c = new FrmCadMorador(mBL, ((morador)moradorBindingSource.Current));
            c.ShowDialog();
            moradorBindingSource.DataSource = mBL.selecionar();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FrmCadMorador c = new FrmCadMorador(mBL);
            c.ShowDialog();
            moradorBindingSource.DataSource = mBL.selecionar();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            pnlFundo.Visible = false;
            moradorBindingSource.DataSource = mBL.selecionar(txtDesc.Text);
        }

        private void dtGrdVwBloco_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            FrmCadMorador c = new FrmCadMorador(mBL, ((morador)moradorBindingSource.Current));
            c.ShowDialog();
            moradorBindingSource.DataSource = mBL.selecionar();
        }
    }
}
